import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
import naive from 'naive-ui'
import './styles/main.css'


// 引入 vxe-table
import 'xe-utils'
import VXETable from 'vxe-table'
import 'vxe-table/lib/style.css'
import './styles/main.css'
// 导入组件注册函数
import { registerComponents } from './utils/register-components'
//注册SVG雪碧图
import 'virtual:svg-icons-register'

const app = createApp(App)


// 注册全局组件
registerComponents(app)

const pinia = createPinia()
app.use(pinia)
app.use(router)
app.use(naive)
// 注册 vxe-table
app.use(VXETable)

//  确保在注册 Pinia 后导入或使用 Store,初始化 WebSocket 连接
import { useWebSocketStore } from './stores/websocket'
const webSocketStore = useWebSocketStore()
webSocketStore.connect()


const meta = document.createElement('meta')
meta.name = 'naive-ui-style'
document.head.appendChild(meta)

app.mount('#app')
